using MicroMsg.Common.Event;
using MicroMsg.Resource.@string;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using Microsoft.Phone.Shell;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace MicroMsg.UI.Page
{
	public class RegByPhoneStepSetPass : BasePage
	{
		private EventWatcher mWatcherPhoneReg;
		internal Grid LayoutRoot;
		internal Grid sencondRoot;
		internal panelTitle2Line panelTitle;
		internal StackPanel ContentPanel;
		internal TextBlock textBlockPassWord;
		internal WaterMarkPassWordBox textBoxPassWord;
		internal TextBlock textBlock1;
		internal WaterMarkPassWordBox textBoxPassWordAgain;
		internal TextBlock textBlock2;
		private bool _contentLoaded;
		public RegByPhoneStepSetPass()
		{
			this.InitializeComponent();
			this.SetAppBarWording();
		}
		protected override void OnPageIn(object[] object_0)
		{
		}
		protected override void OnPageOut()
		{
			if (this.mWatcherPhoneReg != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_MOBILEREG_SUCCESS, this.mWatcherPhoneReg);
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_MOBILEREG_ERR, this.mWatcherPhoneReg);
			}
		}
		private void onPhoneAuthRegHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.enableAllControls();
			if (evtArgs.mEventID == EventConst.ON_NETSCENE_MOBILEREG_SUCCESS)
			{
				base.GoToPage("/Source/UI/LoginViews/RegStepSetUserName.xaml", new object[]
				{
					new LoginKind(LOGINTYPE.REG_TYPE_PHONE),
					this.textBoxPassWord.Password
				}, false);
				return;
			}
			if (evtArgs.mEventID == EventConst.ON_NETSCENE_MOBILEREG_ERR)
			{
				MMMessageBox.Show(strings.Reg_PhonePass_MsgRegFail, true, "确定");
			}
		}
		private void btnPreviousStep_Click(object sender, EventArgs e)
		{
			base.GoBack();
		}
		private void btnNextStep_Click(object sender, EventArgs e)
		{
			base.Focus();
			if (this.isInputDone())
			{
				this.disableAllControls();
				base.GoToPage("/Source/UI/LoginViews/RegStepSetUserName.xaml", new object[]
				{
					new LoginKind(LOGINTYPE.REG_TYPE_PHONE),
					this.textBoxPassWord.Password
				}, false);
			}
		}
		private void checkIsPassEmpty()
		{
			if (!string.IsNullOrEmpty(this.textBoxPassWord.Password) && !string.IsNullOrEmpty(this.textBoxPassWordAgain.Password))
			{
				(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(true);
				return;
			}
			(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(false);
		}
		private void textBoxPassWord_GotFocus(object sender, RoutedEventArgs e)
		{
		}
		private void textBoxPassWord_PasswordChanged(object sender, RoutedEventArgs e)
		{
			this.checkIsPassEmpty();
		}
		private void textBoxPassWordAgain_GotFocus(object sender, RoutedEventArgs e)
		{
		}
		private void textBoxPassWordAgain_PasswordChanged(object sender, RoutedEventArgs e)
		{
			this.checkIsPassEmpty();
		}
		private void inputTxt_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.get_Key() == 3)
			{
				if (sender == this.textBoxPassWord)
				{
					this.textBoxPassWordAgain.Focus();
					e.set_Handled(true);
					return;
				}
				if (sender == this.textBoxPassWordAgain)
				{
					base.Focus();
					this.btnNextStep_Click(null, null);
				}
			}
		}
		private bool isInputDone()
		{
			if (ToolFunction.checkIsLegalPassWord(this.textBoxPassWord.Password))
			{
				if (this.textBoxPassWord.Password == this.textBoxPassWordAgain.Password)
				{
					return true;
				}
				MessageBoxManager.ShowToast(strings.Reg_PhonePass_MsgPassDiff, 2500, null, false);
			}
			else
			{
				MessageBoxManager.ShowToast(strings.Reg_PhonePass_MsgBadPass, 2500, null, false);
			}
			return false;
		}
		private void enableAllControls()
		{
			ProcessingCover.releaseProgressBar(this.LayoutRoot);
			(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(true);
		}
		private void disableAllControls()
		{
			ProcessingCover.getProgressBar(this.LayoutRoot, null, null, false, false, null);
			(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(false);
		}
		public void SetAppBarWording()
		{
			if (base.get_ApplicationBar() != null && 1 == base.get_ApplicationBar().get_Buttons().get_Count())
			{
				ApplicationBarIconButton applicationBarIconButton = (ApplicationBarIconButton)base.get_ApplicationBar().get_Buttons().get_Item(0);
				applicationBarIconButton.set_Text(strings.COM_Next);
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/LoginViews/RegByPhoneStepSetPass.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.sencondRoot = (Grid)base.FindName("sencondRoot");
			this.panelTitle = (panelTitle2Line)base.FindName("panelTitle");
			this.ContentPanel = (StackPanel)base.FindName("ContentPanel");
			this.textBlockPassWord = (TextBlock)base.FindName("textBlockPassWord");
			this.textBoxPassWord = (WaterMarkPassWordBox)base.FindName("textBoxPassWord");
			this.textBlock1 = (TextBlock)base.FindName("textBlock1");
			this.textBoxPassWordAgain = (WaterMarkPassWordBox)base.FindName("textBoxPassWordAgain");
			this.textBlock2 = (TextBlock)base.FindName("textBlock2");
		}
	}
}
